﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace SARUserControls
{
	/// <summary>
	/// 打开文件对话框
	/// </summary>
	public partial class DaKaiWenJianDialog : Window
	{
		public DaKaiWenJianDialog()
		{
			this.InitializeComponent();
			
			// 在此点之下插入创建对象所需的代码。
		}

        private void gridTitle_MouseMove(object sender, MouseEventArgs e)
        {
            if (e.LeftButton == MouseButtonState.Pressed)
            {
                this.DragMove();
            }
        }

        /// <summary>
        /// OK按钮被单击了
        /// </summary>
        public event DakaiWenjianOKHandler SAROKClick;

        /// <summary>
        /// 取消按钮被单击了
        /// </summary>
        public event CancelClickHandler SARCancelClick;

        private void btnOk_SARPreClick(object sender, MouseButtonEventArgs e)
        {
            if (SAROKClick != null)
            {
                SAROKClick.Invoke(txtWidth.SARContentTxt, txtHeight.SARContentTxt);
            }
            this.Close();
        }

        private void btnCancel_SARNextClick(object sender, MouseButtonEventArgs e)
        {
            if (SARCancelClick != null)
            {
                SARCancelClick.Invoke();
            }
            this.Close();
        }

        private void closeMouseCapture_MouseEnter(object sender, MouseEventArgs e)
        {
            this.closeMouseCapture.Opacity = 1;
        }

        private void closeMouseCapture_MouseLeave(object sender, MouseEventArgs e)
        {
            this.closeMouseCapture.Opacity = 0;
        }

        private void closeMouseCapture_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            if (SARCancelClick != null)
            {
                SARCancelClick.Invoke();
            }
            this.Close();
        }
    }	

    /// <summary>
    /// 打开文件OK单击事件处理函数委托类型
    /// </summary>
    /// <param name="width"></param>
    /// <param name="height"></param>
    public delegate void DakaiWenjianOKHandler(double width,double height);    
}